package com.kara.webapp.pages.admin.student;

import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.kara.entity.Clazz;
import com.kara.service.ClazzManager;
import com.kara.webapp.components.student.StudentForm;


public class StudentEdit {


  @Inject
  private ClazzManager clazzManager;
  
  @Component(parameters= {"clazzId=clazzId", "studentId=studentId"})
  private StudentForm form;
  
  private Clazz clazz;

  @Property
  private long clazzId;
  
  @Property
  private long studentId;
  
  @SetupRender
  public void setUp() {
	  clazz = clazzManager.getClazz(clazzId);
	  
  }
  public void setCurrentClazzId(long clazzId){
	  this.clazzId = clazzId;
  }
  
 
  void onActivate(long clazzId){
	  this.clazzId = clazzId;
  }
  
  Object onPassivate(){
	  if (studentId >0){
		  return  new Object []  { this.clazzId, this.studentId};
	  }
	  else {
		  return this.clazzId;
	  }
  }
  void onActivate(long clazzId, long studentId){
	  this.clazzId=clazzId;
	  this.studentId = studentId;
  }
public void setCurrentStudentId(long actionStudentId) {
	this.studentId = actionStudentId;
}
}
